package com.micro.train.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.micro.train.entity.TrainCarriage;
import com.micro.train.repository.TrainCarriageRepository;
import com.micro.train.service.TrainCarriageService;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 列车车厢服务实现类
 * 
 * @author micro
 * @since 1.0.0
 */
@Service
public class TrainCarriageServiceImpl extends ServiceImpl<TrainCarriageRepository, TrainCarriage> implements TrainCarriageService {

    @Override
    public List<TrainCarriage> getCarriagesByTrainId(Long trainId) {
        QueryWrapper<TrainCarriage> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("列车ID", trainId);
        return this.list(queryWrapper);
    }

    @Override
    public List<TrainCarriage> getCarriagesByType(Integer carriageType) {
        QueryWrapper<TrainCarriage> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("车厢类型", carriageType);
        return this.list(queryWrapper);
    }

    @Override
    public List<TrainCarriage> getCarriagesByTrainIdAndType(Long trainId, Integer carriageType) {
        QueryWrapper<TrainCarriage> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("列车ID", trainId)
                   .eq("车厢类型", carriageType);
        return this.list(queryWrapper);
    }
}
